package com.sc.core.make.file.template;

public class Lists {
    public final static String content = """
            <!DOCTYPE html>
            <html lang="en"  xmlns:th="http://www.thymeleaf.org">
            <head>
                <meta charset="UTF-8">
                <title>Home</title>
                <th:block th:replace="~{layouts/common::list}"></th:block>
                <style>
                    [v-cloak] {
                        display: none
                    }
                    .icon-se .el-select-dropdown__item{
                        display: inline-block;
                        width: 80px;
                        text-align: center;
                        font-size: 20px;
                    }
                    .icon-se .el-select-dropdown__list{
                        width: 560px;
                    }
                </style>
            </head>
            <body>
            <div id="app">
                <el-button @click="form">新增</el-button>
                <el-table :data="tableData" style="width: 100%" row-key="id">
                    <items>
                    <el-table-column label="操作">
                        <template #default="scope">
                            <el-link type="primary" size="small" icon="edit" @click="form(scope)">编辑</el-link>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            </body>
            <th:block th:replace="~{<module>/<identity>/form::form}"></th:block>
            <script>
                let { ref, createApp, reactive } = Vue;
                app.create("#app", {
                    setup(){
                        const tableData = ref([]);
                        <optionsDef>
            
                        const theme = ref(sc.tagTheme)
            
                        axios({
                            method: 'get',
                            url: '/admin-<module>/<identity>/list-data',
                            params: {
                                page: 1,
                                pageSize: 10,
                            }
                        }).then(v => {
                            tableData.value = v.data.data;
                        })
            
                         let formEl = administratorsFormEl(),
                             ch = formEl.formEl.outerHTML;
                        <enumRequest>
            
                        function form(scope) {
                            const id = '<identity>-form';
                            layer.open({
                                type: 1,
                                id: id,
                                title: '修改',
                                area: ['800px', '600px'],
                                content: '',
                                success: function(layero, index){
                                    layero.find('#'+id).attr('v-cloak', '').html(ch);
                                    formEl.initData((scope === null || scope instanceof PointerEvent) ? null : scope.row.id)
                                    setTimeout(() => {
                                        formEl.appInit(id)
                                    }, 10)
                                }
                            });
                        }
            
                        return {
                            tableData,
                            <options>
                            theme,
                            form,
                        };
                    }
                });
            </script>
            </html>
            """;

    public final static String enumRequest = """
            sc.axios.get('/admin-<module>/<identity>/get-enum-map', {name: '<enumName>'}).then((res) => {
                            <enumName>.value = res.data;
                            formEl.optionsAssign("<enumName>", <enumName>.value)
                        })
            """;
}
